﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AntiObesity.Base.Managers;
using AntiObesity.Base;

namespace AntiObesity.Services
{
    public partial class SetTarget : SecuredPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var history = BodyHistoryManager.GetLatestHistory(Session.GetCurrentUser().ID);
            lblCurrentWeight.Text = history.Weight.ToString("#.##");
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            // TODO: server side validations

            var targetWieght = (float) Convert.ToDouble(txtTargetWeight.Text);
            TargetHistoryManager.PersistHistory(
                Session.GetCurrentUser().ID,
                targetWieght);

            Response.Redirect("~/UserHome.aspx");
        }

    }
}
